home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / less / dist / patch2 / text0000.txt < prev   
Encoding:
Text File  |  1991-04-04  |  38.9 KB  |  1,652 lines

  1. This is a set of patches to less version 170.
  2.  
  3. Most of the patches included here are bug fixes and
  4. improvements to the documentation (man page and help file).
  5. There are just a few changes to functionality:
  6.  
  7. 1. The N command now reverses the direction of the last search
  8.    initiated by a / or ? command.  In version 170, N reversed
  9.    the direction of the last search, even if the last search
  10.    was initiated by an N command.  The new behavior matches 
  11.    that of vi.
  12.  
  13. 2. The | command now pipes data between the top line on the
  14.    screen and the marked line, inclusive.  This may be less
  15.    than the current screen.  Version 170 did not include the
  16.    marked line, and forced the piped data to include the 
  17.    current screen at a minimum.
  18.  
  19. 3. The LESSBINFMT variable has been extended to allow changing or
  20.    disabling the blinking mode used to display binary characters.
  21.  
  22. 4. A new variable LESSHELP has been added to specify an
  23.    alternate help file.
  24.  
  25. This set of patches INCLUDES patch #1 which was previously 
  26. posted to fix a bug in the -? option.
  27. To minimize the size of this patch, changes to the man page 
  28. nroff source "less.nro" are included, but the corresponding 
  29. changes to the formatted man page "less.man" are not.
  30.  
  31. Mark Nudelman
  32. {uunet,sun,decwrl,hplabs}!pyramid!ctnews!unix386!mark
  33.  
  34. ------------------------- cut here ------------------------- 
  35.  
  36. *** less.170/ch.c    Wed Mar  6 12:16:40 1991
  37. --- less/ch.c    Tue Apr  2 23:38:26 1991
  38. ***************
  39. *** 34,40 ****
  40.    * simply re-reading the file, but a pipe cannot be re-read.
  41.    */
  42.   
  43. ! static struct filestate {
  44.       struct buf *next, *prev;   /* Must be first to match struct buf */
  45.       POSITION fpos;
  46.       int nbufs;
  47. --- 34,40 ----
  48.    * simply re-reading the file, but a pipe cannot be re-read.
  49.    */
  50.   
  51. ! struct filestate {
  52.       struct buf *next, *prev;   /* Must be first to match struct buf */
  53.       POSITION fpos;
  54.       int nbufs;
  55. ***************
  56. *** 65,70 ****
  57. --- 65,71 ----
  58.   extern int sigs;
  59.   #if LOGFILE
  60.   extern int logfile;
  61. + extern char *namelogfile;
  62.   #endif
  63.   
  64.   static int ch_addbuf();
  65. ***************
  66. *** 167,173 ****
  67.        * If we have a log file, write the new data to it.
  68.        */
  69.       if (logfile >= 0 && n > 0)
  70. !         write(logfile, &bp->data[bp->datasize], n);
  71.   #endif
  72.   
  73.       bp->datasize += n;
  74. --- 168,174 ----
  75.        * If we have a log file, write the new data to it.
  76.        */
  77.       if (logfile >= 0 && n > 0)
  78. !         write(logfile, (char *) &bp->data[bp->datasize], n);
  79.   #endif
  80.   
  81.       bp->datasize += n;
  82. ***************
  83. *** 242,247 ****
  84. --- 243,249 ----
  85.       }
  86.       close(logfile);
  87.       logfile = -1;
  88. +     namelogfile = NULL;
  89.   }
  90.   
  91.   /*
  92. ***************
  93. *** 261,267 ****
  94.           for (bp = buf_head;  bp != END_OF_CHAIN;  bp = bp->next)
  95.               if (bp->block == block)
  96.               {
  97. !                 write(logfile, bp->data, bp->datasize);
  98.                   break;
  99.               }
  100.   }
  101. --- 263,269 ----
  102.           for (bp = buf_head;  bp != END_OF_CHAIN;  bp = bp->next)
  103.               if (bp->block == block)
  104.               {
  105. !                 write(logfile, (char *) bp->data, bp->datasize);
  106.                   break;
  107.               }
  108.   }
  109. *** less.170/charset.c    Wed Mar  6 12:16:50 1991
  110. --- less/charset.c    Wed Apr  3 00:50:41 1991
  111. ***************
  112. *** 23,28 ****
  113. --- 23,29 ----
  114.   
  115.   static char chardef[256];
  116.   static char *binfmt = "\\%o";
  117. + public int binattr = BLINK;
  118.   
  119.   extern char *getenv();
  120.   
  121. ***************
  122. *** 147,153 ****
  123.   
  124.       s = getenv("LESSBINFMT");
  125.       if (s != NULL && *s != '\0')
  126. !         binfmt = s;
  127.   }
  128.   
  129.   /*
  130. --- 148,168 ----
  131.   
  132.       s = getenv("LESSBINFMT");
  133.       if (s != NULL && *s != '\0')
  134. !     {
  135. !         if (*s == '*')
  136. !         {
  137. !             switch (s[1])
  138. !             {
  139. !             case 'd':  binattr = BOLD;      break;
  140. !             case 'k':  binattr = BLINK;     break;
  141. !             case 'u':  binattr = UNDERLINE; break;
  142. !             default:   binattr = NORMAL;    break;
  143. !             }
  144. !             s += 2;
  145. !         }
  146. !         if (*s != '\0')
  147. !             binfmt = s;
  148. !     }
  149.   }
  150.   
  151.   /*
  152. *** less.170/command.c    Wed Mar  6 12:16:41 1991
  153. --- less/command.c    Tue Apr  2 20:02:18 1991
  154. ***************
  155. *** 80,86 ****
  156.    * Set up the display to start a new search command.
  157.    */
  158.       static void
  159. ! search_mca()
  160.   {
  161.       switch (SRCH_DIR(search_type))
  162.       {
  163. --- 80,86 ----
  164.    * Set up the display to start a new search command.
  165.    */
  166.       static void
  167. ! mca_search()
  168.   {
  169.       switch (SRCH_DIR(search_type))
  170.       {
  171. ***************
  172. *** 97,116 ****
  173.   
  174.       if (search_type & SRCH_FIRST_FILE)
  175.           cmd_putstr("@");
  176. -     else
  177. -         cmd_putstr(" ");
  178.   
  179.       if (search_type & SRCH_PAST_EOF)
  180.           cmd_putstr("*");
  181. -     else
  182. -         cmd_putstr(" ");
  183.   
  184. -     cmd_putstr(" ");
  185.       if (search_type & SRCH_NOMATCH)
  186.           cmd_putstr("!");
  187. -     else
  188. -         cmd_putstr(" ");
  189.   
  190.       switch (SRCH_DIR(search_type))
  191.       {
  192. --- 97,108 ----
  193. ***************
  194. *** 338,344 ****
  195.           if (flag != 0)
  196.           {
  197.               search_type ^= flag;
  198. !             search_mca();
  199.               return (MCA_MORE);
  200.           }
  201.           break;
  202. --- 330,336 ----
  203.           if (flag != 0)
  204.           {
  205.               search_type ^= flag;
  206. !             mca_search();
  207.               return (MCA_MORE);
  208.           }
  209.           break;
  210. ***************
  211. *** 541,547 ****
  212.       register int nomore;
  213.       char *curr_filename;
  214.       int changed_file;
  215. -     struct scrpos scrpos;
  216.   
  217.       changed_file = 0;
  218.       curr_filename = get_filename(curr_ifile);
  219. --- 533,538 ----
  220. ***************
  221. *** 619,624 ****
  222. --- 610,616 ----
  223.       register int c;
  224.       register int action;
  225.       register char *cbuf;
  226. +     int save_search_type;
  227.       char *s;
  228.       char tbuf[2];
  229.       PARG parg;
  230. ***************
  231. *** 816,822 ****
  232. --- 808,816 ----
  233.                * Forward forever, ignoring EOF.
  234.                */
  235.               cmd_exec();
  236. +             jump_forw();
  237.               ignore_eoi = 1;
  238. +             hit_eof = 0;
  239.               while (sigs == 0)
  240.                   forward(1, 0, 0);
  241.               ignore_eoi = 0;
  242. ***************
  243. *** 928,981 ****
  244.                */
  245.               quit(0);
  246.   
  247. !         case A_B_SEARCH:
  248. !             search_type = SRCH_BACK;
  249. !             goto do_search;
  250.           case A_F_SEARCH:
  251.               search_type = SRCH_FORW;
  252. !         do_search:
  253.               /*
  254. !              * Search for a pattern.
  255.                * Get the first char of the pattern.
  256.                */
  257.               if (number <= 0)
  258.                   number = 1;
  259. !             search_mca();
  260.               c = getcc();
  261.               goto again;
  262.   
  263. !         case A_T_REVERSE_SEARCH:
  264.               search_type |= SRCH_PAST_EOF;
  265. !             /* FALLTHRU */
  266.   
  267.           case A_REVERSE_SEARCH:
  268.               /*
  269.                * Repeat previous search, in reverse direction.
  270.                */
  271. !             c = SRCH_FLAG(search_type);
  272. !             if (SRCH_DIR(search_type) == SRCH_BACK)
  273. !                 search_type = SRCH_FORW;
  274. !             else
  275. !                 search_type = SRCH_BACK;
  276. !             search_type |= c;
  277. !             goto do_again_search;
  278.   
  279. !         case A_T_AGAIN_SEARCH:
  280. !             search_type |= SRCH_PAST_EOF;
  281. !             goto do_again_search;
  282. !         case A_AGAIN_SEARCH:
  283. !             /*
  284. !              * Repeat previous search.
  285.                */
  286. !         do_again_search:
  287. !             if (number <= 0)
  288. !                 number = 1;
  289. !             search_mca();
  290. !             cmd_exec();
  291. !             multi_search((char *)NULL, number);
  292.               break;
  293. !         
  294.           case A_HELP:
  295.               /*
  296.                * Help.
  297. --- 922,997 ----
  298.                */
  299.               quit(0);
  300.   
  301. ! /*
  302. !  * Define abbreviation for a commonly used sequence below.
  303. !  */
  304. ! #define    DO_SEARCH()    if (number <= 0) number = 1;    \
  305. !             mca_search();            \
  306. !             cmd_exec();            \
  307. !             multi_search((char *)NULL, number);
  308.           case A_F_SEARCH:
  309. +             /*
  310. +              * Search forward for a pattern.
  311. +              * Get the first char of the pattern.
  312. +              */
  313.               search_type = SRCH_FORW;
  314. !             if (number <= 0)
  315. !                 number = 1;
  316. !             mca_search();
  317. !             c = getcc();
  318. !             goto again;
  319. !         case A_B_SEARCH:
  320.               /*
  321. !              * Search backward for a pattern.
  322.                * Get the first char of the pattern.
  323.                */
  324. +             search_type = SRCH_BACK;
  325.               if (number <= 0)
  326.                   number = 1;
  327. !             mca_search();
  328.               c = getcc();
  329.               goto again;
  330.   
  331. !         case A_AGAIN_SEARCH:
  332. !             /*
  333. !              * Repeat previous search.
  334. !              */
  335. !             DO_SEARCH();
  336. !             break;
  337. !         
  338. !         case A_T_AGAIN_SEARCH:
  339. !             /*
  340. !              * Repeat previous search, multiple files.
  341. !              */
  342.               search_type |= SRCH_PAST_EOF;
  343. !             DO_SEARCH();
  344. !             break;
  345.   
  346.           case A_REVERSE_SEARCH:
  347.               /*
  348.                * Repeat previous search, in reverse direction.
  349.                */
  350. !             save_search_type = search_type;
  351. !             search_type = SRCH_REVERSE(search_type);
  352. !             DO_SEARCH();
  353. !             search_type = save_search_type;
  354. !             break;
  355.   
  356. !         case A_T_REVERSE_SEARCH:
  357. !             /* 
  358. !              * Repeat previous search, 
  359. !              * multiple files in reverse direction.
  360.                */
  361. !             save_search_type = search_type;
  362. !             search_type = SRCH_REVERSE(search_type);
  363. !             search_type |= SRCH_PAST_EOF;
  364. !             DO_SEARCH();
  365. !             search_type = save_search_type;
  366.               break;
  367.           case A_HELP:
  368.               /*
  369.                * Help.
  370. *** less.170/edit.c    Wed Mar  6 12:16:47 1991
  371. --- less/edit.c    Wed Apr  3 01:14:52 1991
  372. ***************
  373. *** 12,18 ****
  374.   extern int new_file;
  375.   extern int errmsgs;
  376.   extern int quit_at_eof;
  377. - extern int hit_eof;
  378.   extern int file;
  379.   extern int cbufs;
  380.   extern char *every_first_cmd;
  381. --- 12,17 ----
  382. ***************
  383. *** 41,47 ****
  384.       int just_looking;
  385.   {
  386.       register int f;
  387. !     register char *m;
  388.       int answer;
  389.       int no_display;
  390.       struct scrpos scrpos;
  391. --- 40,46 ----
  392.       int just_looking;
  393.   {
  394.       register int f;
  395. !     char *s;
  396.       int answer;
  397.       int no_display;
  398.       struct scrpos scrpos;
  399. ***************
  400. *** 74,80 ****
  401.           error("%s", &parg);
  402.           free(parg.p_string);
  403.           return (1);
  404. !     } else if (!force_open && !just_looking && binary_file(f))
  405.       {
  406.           parg.p_string = filename;
  407.           answer = query("\"%s\" may be a binary file.  Continue? ",
  408. --- 73,79 ----
  409.           error("%s", &parg);
  410.           free(parg.p_string);
  411.           return (1);
  412. !     } else if (!force_open && !just_looking && bin_file(f))
  413.       {
  414.           parg.p_string = filename;
  415.           answer = query("\"%s\" may be a binary file.  Continue? ",
  416. ***************
  417. *** 107,114 ****
  418.       }
  419.   
  420.   #if LOGFILE
  421. !     if (f >= 0 && ISPIPE(f) && namelogfile != NULL && is_tty)
  422. !         use_logfile();
  423.   #endif
  424.   
  425.       /*
  426. --- 106,115 ----
  427.       }
  428.   
  429.   #if LOGFILE
  430. !     s = namelogfile;
  431. !     end_logfile();
  432. !     if (f >= 0 && ISPIPE(f) && s != NULL && is_tty)
  433. !         use_logfile(s);
  434.   #endif
  435.   
  436.       /*
  437. ***************
  438. *** 364,381 ****
  439.    * We take care not to blindly overwrite an existing file.
  440.    */
  441.       public void
  442. ! use_logfile()
  443.   {
  444.       register int exists;
  445.       register int answer;
  446.       PARG parg;
  447.   
  448. -     end_logfile();
  449.       /*
  450.        * {{ We could use access() here. }}
  451.        */
  452. !     exists = open(namelogfile, 0);
  453.       close(exists);
  454.       exists = (exists >= 0);
  455.   
  456. --- 365,381 ----
  457.    * We take care not to blindly overwrite an existing file.
  458.    */
  459.       public void
  460. ! use_logfile(filename)
  461. !     char *filename;
  462.   {
  463.       register int exists;
  464.       register int answer;
  465.       PARG parg;
  466.   
  467.       /*
  468.        * {{ We could use access() here. }}
  469.        */
  470. !     exists = open(filename, 0);
  471.       close(exists);
  472.       exists = (exists >= 0);
  473.   
  474. ***************
  475. *** 394,400 ****
  476.           /*
  477.            * Ask user what to do.
  478.            */
  479. !         parg.p_string = namelogfile;
  480.           answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
  481.       }
  482.   
  483. --- 394,400 ----
  484.           /*
  485.            * Ask user what to do.
  486.            */
  487. !         parg.p_string = filename;
  488.           answer = query("Warning: \"%s\" exists; Overwrite, Append or Don't log? ", &parg);
  489.       }
  490.   
  491. ***************
  492. *** 405,411 ****
  493.           /*
  494.            * Overwrite: create the file.
  495.            */
  496. !         logfile = creat(namelogfile, 0644);
  497.           break;
  498.       case 'A': case 'a':
  499.           /*
  500. --- 405,411 ----
  501.           /*
  502.            * Overwrite: create the file.
  503.            */
  504. !         logfile = creat(filename, 0644);
  505.           break;
  506.       case 'A': case 'a':
  507.           /*
  508. ***************
  509. *** 412,420 ****
  510.            * Append: open the file and seek to the end.
  511.            */
  512.   #if __MSDOS__
  513. !         logfile = open(namelogfile, O_APPEND|O_WRONLY);
  514.   #else
  515. !         logfile = open(namelogfile, 1);
  516.   #endif
  517.           if (lseek(logfile, (offset_t)0, 2) == BAD_LSEEK)
  518.           {
  519. --- 412,420 ----
  520.            * Append: open the file and seek to the end.
  521.            */
  522.   #if __MSDOS__
  523. !         logfile = open(filename, O_APPEND|O_WRONLY);
  524.   #else
  525. !         logfile = open(filename, 1);
  526.   #endif
  527.           if (lseek(logfile, (offset_t)0, 2) == BAD_LSEEK)
  528.           {
  529. ***************
  530. *** 443,449 ****
  531.           /*
  532.            * Error in opening logfile.
  533.            */
  534. !         parg.p_string = namelogfile;
  535.           error("Cannot write to \"%s\"", &parg);
  536.       }
  537.   }
  538. --- 443,449 ----
  539.           /*
  540.            * Error in opening logfile.
  541.            */
  542. !         parg.p_string = filename;
  543.           error("Cannot write to \"%s\"", &parg);
  544.       }
  545.   }
  546. *** less.170/filename.c    Wed Mar  6 12:16:50 1991
  547. --- less/filename.c    Wed Apr  3 01:14:44 1991
  548. ***************
  549. *** 62,67 ****
  550. --- 62,68 ----
  551.       public char *
  552.   find_helpfile()
  553.   {
  554. +     register char *helpfile;
  555.   #if __MSDOS__
  556.       extern char *searchpath();
  557.   
  558. ***************
  559. *** 78,85 ****
  560.           helpfile = HELPFILE;
  561.       else
  562.           helpfile++;
  563. !     return (searchpath(helpfile));
  564.   #else
  565.       return (save(HELPFILE));
  566.   #endif
  567.   }
  568. --- 79,88 ----
  569.           helpfile = HELPFILE;
  570.       else
  571.           helpfile++;
  572. !     return (save(searchpath(helpfile)));
  573.   #else
  574. +     if ((helpfile = getenv("LESSHELP")) != NULL)
  575. +         return (save(helpfile));
  576.       return (save(HELPFILE));
  577.   #endif
  578.   }
  579. ***************
  580. *** 154,160 ****
  581.    * This is just a guess, and we need not try too hard to make it accurate.
  582.    */
  583.       int
  584. ! binary_file(f)
  585.       int f;
  586.   {
  587.       int i;
  588. --- 157,163 ----
  589.    * This is just a guess, and we need not try too hard to make it accurate.
  590.    */
  591.       int
  592. ! bin_file(f)
  593.       int f;
  594.   {
  595.       int i;
  596. *** less.170/forwback.c    Wed Mar  6 12:16:52 1991
  597. --- less/forwback.c    Sun Mar 10 17:47:17 1991
  598. ***************
  599. *** 44,49 ****
  600. --- 44,51 ----
  601.   {
  602.       POSITION pos;
  603.   
  604. +     if (ignore_eoi)
  605. +         return;
  606.       if (sigs)
  607.           return;
  608.       /*
  609. ***************
  610. *** 213,219 ****
  611.           put_line();
  612.       }
  613.   
  614. !     if (eof && !sigs)
  615.           hit_eof++;
  616.       else
  617.           eof_check();
  618. --- 215,223 ----
  619.           put_line();
  620.       }
  621.   
  622. !     if (ignore_eoi)
  623. !         hit_eof = 0;
  624. !     else if (eof && !sigs)
  625.           hit_eof++;
  626.       else
  627.           eof_check();
  628. *** less.170/funcs.h    Wed Mar  6 12:17:02 1991
  629. --- less/funcs.h    Tue Apr  2 18:48:25 1991
  630. ***************
  631. *** 172,178 ****
  632.       public HANDLER winch ();
  633.       public void init_signals ();
  634.       public void psignals ();
  635. !     public int findtag ();
  636.       public int tagsearch ();
  637.       public void open_getchr ();
  638.       public int getchr ();
  639. --- 172,178 ----
  640.       public HANDLER winch ();
  641.       public void init_signals ();
  642.       public void psignals ();
  643. !     public void findtag ();
  644.       public int tagsearch ();
  645.       public void open_getchr ();
  646.       public int getchr ();
  647. *** less.170/ifile.c    Wed Mar  6 12:16:52 1991
  648. --- less/ifile.c    Wed Mar  6 11:56:31 1991
  649. ***************
  650. *** 153,158 ****
  651. --- 153,160 ----
  652.   get_filename(ifile)
  653.       IFILE ifile;
  654.   {
  655. +     if (ifile == NULL)
  656. +         return (NULL);
  657.       return (int_ifile(ifile)->h_filename);
  658.   }
  659.   
  660. *** less.170/jump.c    Wed Mar  6 12:16:52 1991
  661. --- less/jump.c    Fri Mar 15 22:44:16 1991
  662. ***************
  663. *** 17,22 ****
  664. --- 17,24 ----
  665.       public void
  666.   jump_forw()
  667.   {
  668. +     POSITION pos;
  669.       if (ch_end_seek())
  670.       {
  671.           error("Cannot seek to end of file", NULL_PARG);
  672. ***************
  673. *** 24,31 ****
  674.       }
  675.       /*
  676.        * Position the last line in the file at the last screen line.
  677.        */
  678. !     jump_loc(back_line(ch_tell()), sc_height-1);
  679.   }
  680.   
  681.   /*
  682. --- 26,39 ----
  683.       }
  684.       /*
  685.        * Position the last line in the file at the last screen line.
  686. +      * Go back one line from the end of the file
  687. +      * to get to the beginning of the last line.
  688.        */
  689. !     pos = back_line(ch_tell());
  690. !     if (pos == NULL_POSITION)
  691. !         jump_loc((POSITION)0, sc_height-1);
  692. !     else
  693. !         jump_loc(pos, sc_height-1);
  694.   }
  695.   
  696.   /*
  697. *** less.170/less.h    Wed Mar  6 12:16:38 1991
  698. --- less/less.h    Sun Mar 17 22:49:59 1991
  699. ***************
  700. *** 89,96 ****
  701.   #define    SRCH_PAST_EOF    0200    /* Search past end-of-file, into next file */
  702.   #define    SRCH_FIRST_FILE    0400    /* Search starting at the first file */
  703.   
  704. ! #define    SRCH_DIR(t)    ((t) & 077)
  705. ! #define    SRCH_FLAG(t)    ((t) & 07700)
  706.   
  707.   /* Special chars used to tell put_line() to do something special */
  708.   #define    NORMAL        (0)
  709. --- 89,96 ----
  710.   #define    SRCH_PAST_EOF    0200    /* Search past end-of-file, into next file */
  711.   #define    SRCH_FIRST_FILE    0400    /* Search starting at the first file */
  712.   
  713. ! #define    SRCH_DIR(t)    ((t) & 01)
  714. ! #define    SRCH_REVERSE(t)    ((t) ^ 01)
  715.   
  716.   /* Special chars used to tell put_line() to do something special */
  717.   #define    NORMAL        (0)
  718. *** less.170/less.hlp    Wed Mar  6 12:16:54 1991
  719. --- less/less.hlp    Thu Mar 28 15:07:17 1991
  720. ***************
  721. *** 24,34 ****
  722.   
  723.     /pattern          *  Search forward for (N-th) matching line.
  724.     ?pattern          *  Search backward for (N-th) matching line.
  725. -   ESC-/pattern      *  Search all files for (N-th) matching line.
  726.   
  727. !   /!pattern         *  Search forward for (N-th) NON-matching line.
  728. !   ?!pattern         *  Search backward for (N-th) NON-matching line.
  729. !   ESC-/!pattern     *  Search from all files for (N-th) NON-matching line.
  730.   
  731.     n                 *  Repeat previous search (for N-th occurrence).
  732.     N                 *  Repeat previous search in reverse direction.
  733. --- 24,34 ----
  734.   
  735.     /pattern          *  Search forward for (N-th) matching line.
  736.     ?pattern          *  Search backward for (N-th) matching line.
  737.   
  738. !   NOTE: search commands may be modified by one or more of:
  739. !         !  search for NON-matching lines.
  740. !         *  search multiple files.
  741. !         @  start search at first file (for /) or last file (for ?).
  742.   
  743.     n                 *  Repeat previous search (for N-th occurrence).
  744.     N                 *  Repeat previous search in reverse direction.
  745. ***************
  746. *** 38,49 ****
  747.     g  <  ESC-<       *  Go to first line in file (or line N).
  748.     G  >  ESC->       *  Go to last line in file (or line N).
  749.     p  %              *  Go to beginning of file (or N percent into file).
  750. !   {                 *  Go to the } which matches the (N-th) { in the top line.
  751. !   }                 *  Go to the { which matches the (N-th) } in the top line.
  752. !   (                 *  Go to the ) which matches the (N-th) ( in the top line.
  753. !   )                 *  Go to the ( which matches the (N-th) ) in the top line.
  754. !   [                 *  Go to the ] which matches the (N-th) [ in the top line.
  755. !   ]                 *  Go to the [ which matches the (N-th) ] in the top line.
  756.     m<letter>            Mark the current position with <letter>.
  757.     '<letter>            Go to a previously marked position.
  758.     ''                   Go to the previous position.
  759. --- 38,51 ----
  760.     g  <  ESC-<       *  Go to first line in file (or line N).
  761.     G  >  ESC->       *  Go to last line in file (or line N).
  762.     p  %              *  Go to beginning of file (or N percent into file).
  763. !   {                 *  Go to the } matching the (N-th) { in the top line.
  764. !   }                 *  Go to the { matching the (N-th) } in the bottom line.
  765. !   (                 *  Go to the ) matching the (N-th) ( in the top line.
  766. !   )                 *  Go to the ( matching the (N-th) ) in the bottom line.
  767. !   [                 *  Go to the ] matching the (N-th) [ in the top line.
  768. !   ]                 *  Go to the [ matching the (N-th) ] in the bottom line.
  769. !   ESC-^F <c1> <c2>  *  Go to the c1 matching the (N-th) c2 in the top line
  770. !   ESC-^B <c1> <c2>  *  Go to the c2 matching the (N-th) c1 in the bottom line.
  771.     m<letter>            Mark the current position with <letter>.
  772.     '<letter>            Go to a previously marked position.
  773.     ''                   Go to the previous position.
  774. ***************
  775. *** 70,75 ****
  776. --- 72,78 ----
  777.           Most flags may be changed either on the command line,
  778.           or from within less by using the - command.
  779.   
  780. +   -?            Display help (from command line).
  781.     -a            Set forward search starting location.
  782.     -b [N]        Number of buffers.
  783.     -B            Automatically allocate buffers.
  784. ***************
  785. *** 81,94 ****
  786.     -i            Ignore case in searches.
  787.     -j [N]        Screen position of target lines.
  788.     -k [file]     Use a lesskey file.
  789. -   -l [file]     Log file.
  790. -   -L [file]     Log file (unconditionally overwrite).
  791.     -m  -M        Set prompt style.
  792.     -n  -N        Use line numbers.
  793.     -P [prompt]   Define new prompt.
  794.     -q  -Q        Quiet the terminal bell.
  795. !   -r  -R        Translate control characters.
  796.     -s            Squeeze multiple blank lines.
  797.     -t [tag]      Find a tag.
  798.     -T [tagsfile] Use an alternate tags file.
  799.     -u  -U        Change handling of backspaces.
  800. --- 84,99 ----
  801.     -i            Ignore case in searches.
  802.     -j [N]        Screen position of target lines.
  803.     -k [file]     Use a lesskey file.
  804.     -m  -M        Set prompt style.
  805.     -n  -N        Use line numbers.
  806. +   -o [file]     Log file.
  807. +   -O [file]     Log file (unconditionally overwrite).
  808. +   -p [pattern]  Start at pattern (from command line).
  809.     -P [prompt]   Define new prompt.
  810.     -q  -Q        Quiet the terminal bell.
  811. !   -r            Translate control characters.
  812.     -s            Squeeze multiple blank lines.
  813. +   -S            Chop long lines.
  814.     -t [tag]      Find a tag.
  815.     -T [tagsfile] Use an alternate tags file.
  816.     -u  -U        Change handling of backspaces.
  817. *** less.170/less.nro    Wed Mar  6 12:16:35 1991
  818. --- less/less.nro    Wed Apr  3 01:00:20 1991
  819. ***************
  820. *** 4,14 ****
  821.   .SH SYNOPSIS
  822.   .B "less -?"
  823.   .br
  824. ! .B "less [-[+]aABcCdeEfimMnNqQrsSuUw] [-b\fIN\fP] [-x\fIN\fP] [-[z]\fIN\fP]"
  825.   .br
  826. ! .B "     [-h\fIN\fP] [-y\fIN\fP] [-P[mM=]\fIstring\fP] [-[oO]\fIlogfile\fP] [-k\fIkeyfile\fP]"
  827.   .br
  828. ! .B "     [-t\fItag\fP] [-T\fItagsfile\fP] [+\fIcmd\fP] [\fIfilename\fP]..."
  829.   
  830.   .SH DESCRIPTION
  831.   .I Less
  832. --- 4,18 ----
  833.   .SH SYNOPSIS
  834.   .B "less -?"
  835.   .br
  836. ! .B "less [-[+]aBcCdeEfHimMnNqQrsSuUw]"
  837.   .br
  838. ! .B "     [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
  839.   .br
  840. ! .B "     [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
  841. ! .br
  842. ! .B "     [-T \fItagfile\fP] [-x \fItab\fP] [-y \fIlines\fP] [-[z] \fIlines\fP]"
  843. ! .br
  844. ! .B "     [+[+]\fIcmd\fP] [\fIfilename\fP]..."
  845.   
  846.   .SH DESCRIPTION
  847.   .I Less
  848. ***************
  849. *** 350,360 ****
  850.   .IP "| <m> shell-command"
  851.   <m> represents any mark letter.
  852.   Pipes a section of the input file to the given shell command.
  853. ! The section of the file to be piped is between the current position and 
  854. ! the position marked by the letter.
  855.   <m> may also be ^ or $ to indicate beginning or end of file respectively.
  856.   If <m> is . or newline, the current screen is piped.
  857. - The current screen is the minimum amount piped in any case.
  858.   .PP
  859.   .SH OPTIONS
  860.   Command line options are described below.
  861. --- 354,363 ----
  862.   .IP "| <m> shell-command"
  863.   <m> represents any mark letter.
  864.   Pipes a section of the input file to the given shell command.
  865. ! The section of the file to be piped is between the first line on
  866. ! the current screen and the position marked by the letter.
  867.   <m> may also be ^ or $ to indicate beginning or end of file respectively.
  868.   If <m> is . or newline, the current screen is piped.
  869.   .PP
  870.   .SH OPTIONS
  871.   Command line options are described below.
  872. ***************
  873. *** 727,732 ****
  874. --- 730,742 ----
  875.   This octal format can be changed by 
  876.   setting the LESSBINFMT environment variable
  877.   to a printf-style format string; the default is '\\%o'.
  878. + The blinking mode display of control and binary characters can
  879. + be changed or disabled by preceding the LESSBINFMT format 
  880. + string with a "*" and one character to select the mode:
  881. + "*k" is blinking, "*d" is bold, "*u" is underlined,
  882. + and "*n" is normal (no special display attribute).
  883. + For example, if LESSBINFMT is "*u[%x]", binary characters
  884. + are displayed in underlined hexadecimal surrounded by brackets.
  885.   
  886.   .SH "PROMPTS"
  887.   The -P option allows you to tailor the prompt to your preference.
  888. ***************
  889. *** 907,912 ****
  890. --- 917,924 ----
  891.   .IP LESSEDIT
  892.   Editor prototype string (used for the v command).
  893.   See discussion under PROMPTS.
  894. + .IP LESSHELP
  895. + Name of the help file.
  896.   .IP LINES
  897.   Sets the number of lines on the screen.
  898.   Takes precedence over the number of lines specified by the TERM variable.
  899. *** less.170/lesskey.c    Wed Mar  6 12:16:40 1991
  900. --- less/lesskey.c    Thu Mar 14 13:09:10 1991
  901. ***************
  902. *** 307,312 ****
  903. --- 307,313 ----
  904.           perror(outfile);
  905.       else
  906.           fwrite((char *)usertable, 1, up-usertable, out);
  907. +     exit(0);
  908.   }
  909.   
  910.   /*
  911. *** less.170/line.c    Wed Mar  6 12:16:44 1991
  912. --- less/line.c    Wed Apr  3 00:45:15 1991
  913. ***************
  914. *** 15,25 ****
  915. --- 15,28 ----
  916.   static int is_null_line;    /* There is no current line */
  917.   static char pendc;
  918.   
  919. + static int do_append();
  920.   extern int bs_mode;
  921.   extern int tabstop;
  922.   extern int linenums;
  923.   extern int ctldisp;
  924.   extern int twiddle;
  925. + extern int binattr;
  926.   extern int auto_wrap, ignaw;
  927.   extern int bo_s_width, bo_e_width;
  928.   extern int ul_s_width, ul_e_width;
  929. ***************
  930. *** 332,338 ****
  931.                * Output in the (blinking) ^X format.
  932.                */
  933.               s = prchar(c);  
  934. !             a = BLINK;
  935.   
  936.               /*
  937.                * Make sure we can get the entire representation
  938. --- 335,341 ----
  939.                * Output in the (blinking) ^X format.
  940.                */
  941.               s = prchar(c);  
  942. !             a = binattr;
  943.   
  944.               /*
  945.                * Make sure we can get the entire representation
  946. ***************
  947. *** 360,367 ****
  948.   pdone(endline)
  949.       int endline;
  950.   {
  951. -     register char c;
  952.       if (pendc && (pendc != '\r' || !endline))
  953.           /*
  954.            * If we had a pending character, put it in the buffer.
  955. --- 363,368 ----
  956. ***************
  957. *** 374,380 ****
  958.        * Add a newline if necessary,
  959.        * and append a '\0' to the end of the line.
  960.        */
  961. !     if (column < sc_width || !auto_wrap || ignaw)
  962.       {
  963.           linebuf[curr] = '\n';
  964.           attr[curr] = NORMAL;
  965. --- 375,381 ----
  966.        * Add a newline if necessary,
  967.        * and append a '\0' to the end of the line.
  968.        */
  969. !     if (column < sc_width || !auto_wrap || ignaw || ctldisp == 0)
  970.       {
  971.           linebuf[curr] = '\n';
  972.           attr[curr] = NORMAL;
  973. *** less.170/linstall    Wed Mar  6 12:16:34 1991
  974. --- less/linstall    Thu Mar 28 14:42:41 1991
  975. ***************
  976. *** 143,158 ****
  977.    * 0 if it does not.
  978.    */
  979.   #define    VOID        $x
  980. - #if VOID
  981. - #define    VOID_POINTER    void *
  982. - #else
  983. - #define    VOID_POINTER    char *
  984. - #endif
  985.   
  986.   EOF
  987.   
  988.   
  989.   
  990.   def=long
  991.   if [ $alldefault = 0 ]
  992.   then
  993. --- 143,175 ----
  994.    * 0 if it does not.
  995.    */
  996.   #define    VOID        $x
  997.   
  998.   EOF
  999.   
  1000.   
  1001.   
  1002. + def=yes
  1003. + x="void *"
  1004. + if [ $alldefault = 0 ]
  1005. + then
  1006. +     $ECHO "Does your C compiler support the \"void *\" type? [$def] \c"
  1007. +     read ans
  1008. +     case "X$ans" in
  1009. +     X[yY]*) x="void *" ;;
  1010. +     X[nN]*) x="char *" ;;
  1011. +     esac
  1012. +     $ECHO ""
  1013. + fi
  1014. + cat >>defines.h <<EOF
  1015. + /*
  1016. +  * VOID_POINTER is the definition of a pointer to any object.
  1017. +  */
  1018. + #define    VOID_POINTER    $x
  1019. + EOF
  1020.   def=long
  1021.   if [ $alldefault = 0 ]
  1022.   then
  1023. ***************
  1024. *** 370,375 ****
  1025. --- 387,421 ----
  1026.   
  1027.   EOF
  1028.   
  1029. + if [ "$sys" = "sys5" -a "$xenix" = "0" ]
  1030. + then
  1031. +     def=yes; x=1
  1032. + else
  1033. +     def=no; x=0
  1034. + fi
  1035. + if [ $alldefault = 0 ]
  1036. + then
  1037. +     $ECHO "Some SCO System V systems need sys/ptem.h included to get"
  1038. +     $ECHO "the size of the screen (struct winsize)."
  1039. +     $ECHO "Does your system need sys/ptem.h? [$def] \c"
  1040. +     read ans
  1041. +     case "X$ans" in
  1042. +     X[yY]*) x=1 ;;
  1043. +     X[nN]*) x=0 ;;
  1044. +     esac
  1045. +     $ECHO ""
  1046. + fi
  1047. + cat >>defines.h <<EOF
  1048. + /*
  1049. +  * NEED_PTEM_H is 1 if your system needs sys/ptem.h to declare struct winsize.
  1050. +  * This is normally the case only for SCOs System V.
  1051. +  */
  1052. + #define    NEED_PTEM_H    $x
  1053. + EOF
  1054.   
  1055.   
  1056.   if [ "$sys" = "bsd" ]
  1057. *** less.170/lsystem.c    Wed Mar  6 12:16:51 1991
  1058. --- less/lsystem.c    Tue Apr  2 23:54:18 1991
  1059. ***************
  1060. *** 205,218 ****
  1061.       tpos = position(TOP);
  1062.       if (tpos == NULL_POSITION)
  1063.           tpos = ch_zero();
  1064. !     bpos = position(BOTTOM_PLUS_ONE);
  1065.   
  1066. !     if (mpos <= tpos)
  1067. !         return (pipe_data(cmd, mpos, bpos));
  1068. !     else if (bpos == NULL_POSITION || mpos <= bpos)
  1069. !         return (pipe_data(cmd, tpos, bpos));
  1070. !     else
  1071. !         return (pipe_data(cmd, tpos, mpos));
  1072.   }
  1073.   
  1074.   /*
  1075. --- 205,220 ----
  1076.       tpos = position(TOP);
  1077.       if (tpos == NULL_POSITION)
  1078.           tpos = ch_zero();
  1079. !     bpos = position(BOTTOM);
  1080.   
  1081. !      if (c == '.') 
  1082. !          return (pipe_data(cmd, tpos, bpos));
  1083. !      else if (mpos <= tpos)
  1084. !          return (pipe_data(cmd, mpos, tpos));
  1085. !      else if (bpos == NULL_POSITION)
  1086. !          return (pipe_data(cmd, tpos, bpos));
  1087. !      else
  1088. !          return (pipe_data(cmd, tpos, mpos));
  1089.   }
  1090.   
  1091.   /*
  1092. ***************
  1093. *** 227,233 ****
  1094.   {
  1095.       register FILE *f;
  1096.       register int c;
  1097. -     int inp;
  1098.       extern FILE *popen();
  1099.   
  1100.       /*
  1101. --- 229,234 ----
  1102. ***************
  1103. *** 257,264 ****
  1104.       flush();
  1105.       raw_mode(0);
  1106.       init_signals(0);
  1107.   
  1108. !     while (epos == NULL_POSITION || spos++ < epos)
  1109.       {
  1110.           /*
  1111.            * Read a character from the file and give it to the pipe.
  1112. --- 258,268 ----
  1113.       flush();
  1114.       raw_mode(0);
  1115.       init_signals(0);
  1116. + #ifdef SIGPIPE
  1117. +     SIGNAL(SIGPIPE, SIG_IGN);
  1118. + #endif
  1119.   
  1120. !     while (epos == NULL_POSITION || spos++ <= epos)
  1121.       {
  1122.           /*
  1123.            * Read a character from the file and give it to the pipe.
  1124. ***************
  1125. *** 266,275 ****
  1126.           c = ch_forw_get();
  1127.           if (c == EOI)
  1128.               break;
  1129. !         putc(c, f);
  1130.       }
  1131.       pclose(f);
  1132.   
  1133.       init_signals(1);
  1134.       raw_mode(1);
  1135.       init();
  1136. --- 270,296 ----
  1137.           c = ch_forw_get();
  1138.           if (c == EOI)
  1139.               break;
  1140. !         if (putc(c, f) == EOF)
  1141. !             break;
  1142.       }
  1143. +     /*
  1144. +      * Finish up the last line.
  1145. +      */
  1146. +      while (c != '\n' && c != EOI ) 
  1147. +      {
  1148. +          c = ch_forw_get();
  1149. +          if (c == EOI)
  1150. +              break;
  1151. +          if (putc(c, f) == EOF)
  1152. +              break;
  1153. +      }
  1154.       pclose(f);
  1155.   
  1156. + #ifdef SIGPIPE
  1157. +     SIGNAL(SIGPIPE, SIG_DFL);
  1158. + #endif
  1159.       init_signals(1);
  1160.       raw_mode(1);
  1161.       init();
  1162. *** less.170/main.c    Wed Mar  6 12:16:46 1991
  1163. --- less/main.c    Thu Mar 14 15:23:09 1991
  1164. ***************
  1165. *** 19,25 ****
  1166.   
  1167.   extern int    file;
  1168.   extern int    quit_at_eof;
  1169. - extern int    hit_eof;
  1170.   extern int    cbufs;
  1171.   extern int    errmsgs;
  1172.   extern int    screen_trashed;
  1173. --- 19,24 ----
  1174. ***************
  1175. *** 157,162 ****
  1176. --- 156,162 ----
  1177.               quit(1);
  1178.           if (edit(tagfile, 0) || tagsearch())
  1179.               quit(1);
  1180. +         nofiles = 0;
  1181.       } else
  1182.   #endif
  1183.       if (nifile() == 0)
  1184. *** less.170/optfunc.c    Wed Mar  6 12:16:49 1991
  1185. --- less/optfunc.c    Mon Mar 18 18:29:43 1991
  1186. ***************
  1187. *** 76,82 ****
  1188.           namelogfile = glob(s);
  1189.           if (namelogfile == NULL)
  1190.               namelogfile = save(s);
  1191. !         use_logfile();
  1192.           sync_logfile();
  1193.           break;
  1194.       case QUERY:
  1195. --- 76,82 ----
  1196.           namelogfile = glob(s);
  1197.           if (namelogfile == NULL)
  1198.               namelogfile = save(s);
  1199. !         use_logfile(s);
  1200.           sync_logfile();
  1201.           break;
  1202.       case QUERY:
  1203. *** less.170/option.c    Wed Mar  6 12:16:48 1991
  1204. --- less/option.c    Tue Apr  2 20:59:39 1991
  1205. ***************
  1206. *** 15,20 ****
  1207. --- 15,21 ----
  1208.   
  1209.   static char *propt();
  1210.   static char *optstring();
  1211. + static int flip_triple();
  1212.   
  1213.   extern int screen_trashed;
  1214.   extern char *every_first_cmd;
  1215. ***************
  1216. *** 82,88 ****
  1217.               plusoption = 1;
  1218.               if (*s == '+')
  1219.                   every_first_cmd = save(++s);
  1220. !             ungetsc(s);
  1221.               s = optstring(s, c);
  1222.               continue;
  1223.           case '0':  case '1':  case '2':  case '3':  case '4':
  1224. --- 83,90 ----
  1225.               plusoption = 1;
  1226.               if (*s == '+')
  1227.                   every_first_cmd = save(++s);
  1228. !             else
  1229. !                 ungetsc(s);
  1230.               s = optstring(s, c);
  1231.               continue;
  1232.           case '0':  case '1':  case '2':  case '3':  case '4':
  1233. ***************
  1234. *** 122,128 ****
  1235.               if (set_default)
  1236.                   *(o->ovar) = o->odefault;
  1237.               else
  1238. !                 *(o->ovar) = toggle_triple(o->odefault,
  1239.                           (o->oletter == c));
  1240.               break;
  1241.           case STRING:
  1242. --- 124,130 ----
  1243.               if (set_default)
  1244.                   *(o->ovar) = o->odefault;
  1245.               else
  1246. !                 *(o->ovar) = flip_triple(o->odefault,
  1247.                           (o->oletter == c));
  1248.               break;
  1249.           case STRING:
  1250. ***************
  1251. *** 244,250 ****
  1252.               switch (how_toggle)
  1253.               {
  1254.               case OPT_TOGGLE:
  1255. !                 *(o->ovar) = toggle_triple(*(o->ovar), 
  1256.                           o->oletter == c);
  1257.                   break;
  1258.               case OPT_UNSET:
  1259. --- 246,252 ----
  1260.               switch (how_toggle)
  1261.               {
  1262.               case OPT_TOGGLE:
  1263. !                 *(o->ovar) = flip_triple(*(o->ovar), 
  1264.                           o->oletter == c);
  1265.                   break;
  1266.               case OPT_UNSET:
  1267. ***************
  1268. *** 251,257 ****
  1269.                   *(o->ovar) = o->odefault;
  1270.                   break;
  1271.               case OPT_SET:
  1272. !                 *(o->ovar) = toggle_triple(o->odefault,
  1273.                           o->oletter == c);
  1274.                   break;
  1275.               }
  1276. --- 253,259 ----
  1277.                   *(o->ovar) = o->odefault;
  1278.                   break;
  1279.               case OPT_SET:
  1280. !                 *(o->ovar) = flip_triple(o->odefault,
  1281.                           o->oletter == c);
  1282.                   break;
  1283.               }
  1284. ***************
  1285. *** 335,341 ****
  1286.    * "Toggle" a triple-valued option.
  1287.    */
  1288.       static int
  1289. ! toggle_triple(val, lc)
  1290.       int val;
  1291.       int lc;
  1292.   {
  1293. --- 337,343 ----
  1294.    * "Toggle" a triple-valued option.
  1295.    */
  1296.       static int
  1297. ! flip_triple(val, lc)
  1298.       int val;
  1299.       int lc;
  1300.   {
  1301. *** less.170/screen.c    Wed Mar  6 12:16:55 1991
  1302. --- less/screen.c    Wed Apr  3 01:14:08 1991
  1303. ***************
  1304. *** 31,37 ****
  1305. --- 31,46 ----
  1306.   #endif
  1307.   #endif
  1308.   
  1309. + #if NEED_PTEM_H && defined(TIOCGWINSZ)
  1310.   /*
  1311. +  * All this just to get struct winsize.  Sigh.
  1312. +  */
  1313. + #include <sys/types.h>
  1314. + #include <sys/stream.h>
  1315. + #include <sys/ptem.h>
  1316. + #endif
  1317. + /*
  1318.    * Strings passed to tputs() to do various terminal functions.
  1319.    */
  1320.   static char
  1321. ***************
  1322. *** 199,205 ****
  1323.    * Get size of the output screen.
  1324.    */
  1325.       public void
  1326. ! get_scrsize(p_height, p_width)
  1327.       int *p_height;
  1328.       int *p_width;
  1329.   {
  1330. --- 208,214 ----
  1331.    * Get size of the output screen.
  1332.    */
  1333.       public void
  1334. ! scrsize(p_height, p_width)
  1335.       int *p_height;
  1336.       int *p_width;
  1337.   {
  1338. ***************
  1339. *** 277,283 ****
  1340.       /*
  1341.        * Get size of the screen.
  1342.        */
  1343. !     get_scrsize(&sc_height, &sc_width);
  1344.       pos_init();
  1345.       if (swindow < 0)
  1346.           swindow = sc_height - 1;
  1347. --- 286,292 ----
  1348.       /*
  1349.        * Get size of the screen.
  1350.        */
  1351. !     scrsize(&sc_height, &sc_width);
  1352.       pos_init();
  1353.       if (swindow < 0)
  1354.           swindow = sc_height - 1;
  1355. ***************
  1356. *** 448,478 ****
  1357.   }
  1358.   
  1359.   /*
  1360. -  * Return the "best" of the two given termcap strings.
  1361. -  * The best, if both exist, is the one with the lower 
  1362. -  * cost (see cost() function).
  1363. -  */
  1364. -     static char *
  1365. - cheaper(t1, t2, doit, def)
  1366. -     char *t1, *t2;
  1367. -     char *doit;
  1368. -     char *def;
  1369. - {
  1370. -     if (*t1 == '\0' && *t2 == '\0')
  1371. -     {
  1372. -         cannot(doit);
  1373. -         return (def);
  1374. -     }
  1375. -     if (*t1 == '\0')
  1376. -         return (t2);
  1377. -     if (*t2 == '\0')
  1378. -         return (t1);
  1379. -     if (cost(t1) < cost(t2))
  1380. -         return (t1);
  1381. -     return (t2);
  1382. - }
  1383. - /*
  1384.    * Return the cost of displaying a termcap string.
  1385.    * We use the trick of calling tputs, but as a char printing function
  1386.    * we give it inc_costcount, which just increments "costcount".
  1387. --- 457,462 ----
  1388. ***************
  1389. *** 496,501 ****
  1390. --- 480,510 ----
  1391.       costcount = 0;
  1392.       tputs(t, sc_height, inc_costcount);
  1393.       return (costcount);
  1394. + }
  1395. + /*
  1396. +  * Return the "best" of the two given termcap strings.
  1397. +  * The best, if both exist, is the one with the lower 
  1398. +  * cost (see cost() function).
  1399. +  */
  1400. +     static char *
  1401. + cheaper(t1, t2, doit, def)
  1402. +     char *t1, *t2;
  1403. +     char *doit;
  1404. +     char *def;
  1405. + {
  1406. +     if (*t1 == '\0' && *t2 == '\0')
  1407. +     {
  1408. +         cannot(doit);
  1409. +         return (def);
  1410. +     }
  1411. +     if (*t1 == '\0')
  1412. +         return (t2);
  1413. +     if (*t2 == '\0')
  1414. +         return (t1);
  1415. +     if (cost(t1) < cost(t2))
  1416. +         return (t1);
  1417. +     return (t2);
  1418.   }
  1419.   
  1420.   
  1421. *** less.170/search.c    Wed Mar  6 12:16:53 1991
  1422. --- less/search.c    Tue Apr  2 16:01:20 1991
  1423. ***************
  1424. *** 10,20 ****
  1425.   
  1426.   extern int sigs;
  1427.   extern int how_search;
  1428. - extern int top_scroll;
  1429. - extern int back_scroll;
  1430.   extern int caseless;
  1431.   extern int linenums;
  1432. - extern int sc_height;
  1433.   extern int jump_sline;
  1434.   
  1435.   /*
  1436. --- 10,17 ----
  1437. ***************
  1438. *** 32,38 ****
  1439.       char *pattern;
  1440.       int n;
  1441.   {
  1442. !     POSITION pos, linepos;
  1443.       register char *p;
  1444.       register char *q;
  1445.       register int goforw;
  1446. --- 29,35 ----
  1447.       char *pattern;
  1448.       int n;
  1449.   {
  1450. !     POSITION pos, linepos, oldpos;
  1451.       register char *p;
  1452.       register char *q;
  1453.       register int goforw;
  1454. ***************
  1455. *** 64,70 ****
  1456.       goforw = (SRCH_DIR(search_type) == SRCH_FORW);
  1457.       want_match = !(search_type & SRCH_NOMATCH);
  1458.   
  1459. !     if (pattern != NULL && (is_caseless = caseless))
  1460.       {
  1461.           /*
  1462.            * Search will ignore case, unless
  1463. --- 61,67 ----
  1464.       goforw = (SRCH_DIR(search_type) == SRCH_FORW);
  1465.       want_match = !(search_type & SRCH_NOMATCH);
  1466.   
  1467. !     if (pattern != NULL && *pattern != '\0' && (is_caseless = caseless))
  1468.       {
  1469.           /*
  1470.            * Search will ignore case, unless
  1471. ***************
  1472. *** 213,218 ****
  1473. --- 210,216 ----
  1474.       }
  1475.   
  1476.       linenum = find_linenum(pos);
  1477. +     oldpos = pos;
  1478.       for (;;)
  1479.       {
  1480.           /*
  1481. ***************
  1482. *** 260,268 ****
  1483.            * If we're using line numbers, we might as well
  1484.            * remember the information we have now (the position
  1485.            * and line number of the current line).
  1486.            */
  1487. !         if (linenums)
  1488.               add_lnum(linenum, pos);
  1489.   
  1490.           if (is_caseless)
  1491.           {
  1492. --- 258,272 ----
  1493.            * If we're using line numbers, we might as well
  1494.            * remember the information we have now (the position
  1495.            * and line number of the current line).
  1496. +          * Don't do it for every line because it slows down
  1497. +          * the search.  Remember the line number only if
  1498. +          * we're "far" from the last place we remembered it.
  1499.            */
  1500. !         if (linenums && abs(pos - oldpos) > 1024)
  1501. !         {
  1502.               add_lnum(linenum, pos);
  1503. +             oldpos = pos;
  1504. +         }
  1505.   
  1506.           if (is_caseless)
  1507.           {
  1508. ***************
  1509. *** 300,306 ****
  1510.           line_match = (re_exec(line) == 1);
  1511.   #else
  1512.   #if REGCOMP
  1513. !         linematch = regexec(regpattern, line);
  1514.   #else
  1515.           line_match = match(pattern, line);
  1516.   #endif
  1517. --- 304,310 ----
  1518.           line_match = (re_exec(line) == 1);
  1519.   #else
  1520.   #if REGCOMP
  1521. !         line_match = regexec(regpattern, line);
  1522.   #else
  1523.           line_match = match(pattern, line);
  1524.   #endif
  1525. *** less.170/tags.c    Wed Mar  6 12:17:00 1991
  1526. --- less/tags.c    Tue Apr  2 18:47:35 1991
  1527. ***************
  1528. *** 20,26 ****
  1529.    * and "tagpattern" to the search pattern which should be used
  1530.    * to find the tag.
  1531.    */
  1532. !     public int
  1533.   findtag(tag)
  1534.       register char *tag;
  1535.   {
  1536. --- 20,26 ----
  1537.    * and "tagpattern" to the search pattern which should be used
  1538.    * to find the tag.
  1539.    */
  1540. !     public void
  1541.   findtag(tag)
  1542.       register char *tag;
  1543.   {
  1544. *** less.170/ttyin.c    Wed Mar  6 12:17:01 1991
  1545. --- less/ttyin.c    Thu Mar 28 14:36:51 1991
  1546. ***************
  1547. *** 26,35 ****
  1548.       tty = open("CON", O_RDONLY|O_BINARY);
  1549.   #else
  1550.       /*
  1551. !      * Just use file descriptor 2, which in Unix
  1552. !      * is usually attached to the screen and keyboard.
  1553.        */
  1554. !     tty = 2;
  1555.   #endif
  1556.   }
  1557.   
  1558. --- 26,39 ----
  1559.       tty = open("CON", O_RDONLY|O_BINARY);
  1560.   #else
  1561.       /*
  1562. !      * Try /dev/tty.
  1563. !      * If that doesn't work, use file descriptor 2,
  1564. !      * which in Unix is usually attached to the screen,
  1565. !      * but also usually lets you read from the keyboard.
  1566.        */
  1567. !     tty = open("/dev/tty", 0);
  1568. !     if (tty < 0)
  1569. !         tty = 2;
  1570.   #endif
  1571.   }
  1572.   
  1573. *** less.170/version.c    Wed Mar  6 12:17:01 1991
  1574. --- less/version.c    Tue Apr  2 20:11:21 1991
  1575. ***************
  1576. *** 251,257 ****
  1577.    *    v141: Add edit_list for editing >1 file.    2/8/90   mark
  1578.    *    v142: Add :x command.                2/10/90  mark
  1579.    *    v143: Add * and @ modifies to search cmds.    2/11/90  mark
  1580. !  *          Change ESC-/ cmd from /@* to /*.
  1581.    *    v144: Messed around with ch_zero;         3/1/90   mark
  1582.    *          no real change.
  1583.    *    v145: Added -R and -v/-V for MSDOS;        3/2/90   mark
  1584. --- 251,257 ----
  1585.    *    v141: Add edit_list for editing >1 file.    2/8/90   mark
  1586.    *    v142: Add :x command.                2/10/90  mark
  1587.    *    v143: Add * and @ modifies to search cmds.    2/11/90  mark
  1588. !  *          Change ESC-/ cmd from /@* to / *.
  1589.    *    v144: Messed around with ch_zero;         3/1/90   mark
  1590.    *          no real change.
  1591.    *    v145: Added -R and -v/-V for MSDOS;        3/2/90   mark
  1592. ***************
  1593. *** 290,295 ****
  1594.    *    v170: Add optimization for BSD _setjmp;        1/17/91  mark
  1595.    *          fix #include ioctl.h TERMIO problem.
  1596.    *          (thanks to Paul Eggert)
  1597.    */
  1598.   
  1599. ! char version[] = "@(#) less  version 170";
  1600. --- 290,315 ----
  1601.    *    v170: Add optimization for BSD _setjmp;        1/17/91  mark
  1602.    *          fix #include ioctl.h TERMIO problem.
  1603.    *          (thanks to Paul Eggert)
  1604. +  *        Posted to USENET.
  1605. +  *    -----------------------------------------------------------------
  1606. +  *    v171: Fix -? bug in get_filename.        3/6/91    mark
  1607. +  *    v172: Fix G bug in empty file.            3/15/91   mark
  1608. +  *          Fix bug with ?\n and -i and uppercase
  1609. +  *          pattern at EOF!
  1610. +  *          (thanks to Paul Eggert)
  1611. +  *    v173: Change N cmd to not permanently change    3/17/91   mark
  1612. +  *          direction. (thanks to Brian Matthews)
  1613. +  *    v174: Fix bug with namelogfile not getting    3/18/91   mark
  1614. +  *          cleared when change files.
  1615. +  *    v175: Fix bug with ++cmd on command line.    3/18/91   mark
  1616. +  *          (thanks to Jim Meyering)
  1617. +  *    v176: Change | to not force current screen,    4/2/91    mark
  1618. +  *          include marked line, start/end from 
  1619. +  *          top of screen.  Improve search speed.
  1620. +  *          (thanks to Don Mears)
  1621. +  *    v177: Add LESSHELP variable.            4/2/91    mark
  1622. +  *          Fix bug with F command with -e.
  1623. +  *          Try /dev/tty for input before using fd 2.
  1624.    */
  1625.   
  1626. ! char version[] = "@(#) less  version 177";
  1627.  
  1628.  
  1629.